﻿/*
 *  设置 工具
 * 
 */

using UnityEngine;


namespace SG
{
    public static class GameSettingTool
    {
        #region 整体质量
        /// <summary>
        /// 设置整体品质
        /// </summary>
        /// <param name="level"></param>
        public static void SetQualityLevel(QualityLevel level)
        {
            switch (level)
            {
                case QualityLevel.High:
                    QualitySettings.SetQualityLevel(0, false);
                    break;
                case QualityLevel.Middle:
                    QualitySettings.SetQualityLevel(1, false);
                    break;
                case QualityLevel.Low:
                    QualitySettings.SetQualityLevel(2, false);
                    break;
                case QualityLevel.Custom:
                    break;
                default:
                    break;
            }
        }
        #endregion

        #region 贴图
        /// <summary>
        /// 贴图质量
        /// </summary>
        /// <param name="level"></param>
        public static void SetMasterTextureLimit(QualityLevel level)
        {
            switch (level)
            {
                case QualityLevel.High:
                    QualitySettings.globalTextureMipmapLimit = 0;
                    break;
                case QualityLevel.Middle:
                    QualitySettings.globalTextureMipmapLimit = 1;
                    break;
                case QualityLevel.Low:
                    QualitySettings.globalTextureMipmapLimit = 2;
                    break;
                default:
                    break;
            }
        }
        public static QualityLevel GetMasterTextureLimit()
        {
            if (QualitySettings.globalTextureMipmapLimit == 0)
                return QualityLevel.High;
            else if (QualitySettings.globalTextureMipmapLimit == 1)
                return QualityLevel.Middle;
            else if (QualitySettings.globalTextureMipmapLimit == 2)
                return QualityLevel.Low;

            return QualityLevel.Low;
        }
        #endregion

        #region 阴影

        public static void SetShadow(QualityLevel level)
        {
            switch (level)
            {
                case QualityLevel.High:
                    QualitySettings.shadowResolution = UnityEngine.ShadowResolution.High;
                    break;
                case QualityLevel.Middle:
                    QualitySettings.shadowResolution = UnityEngine.ShadowResolution.Medium;
                    break;
                case QualityLevel.Low:
                    QualitySettings.shadowResolution = UnityEngine.ShadowResolution.Low;
                    break;
                default:
                    break;
            }
        }

        public static QualityLevel GetShadow()
        {
            if (QualitySettings.shadowResolution == UnityEngine.ShadowResolution.High)
                return QualityLevel.High;
            else if (QualitySettings.shadowResolution == UnityEngine.ShadowResolution.Medium)
                return QualityLevel.Middle;
            else if (QualitySettings.shadowResolution == UnityEngine.ShadowResolution.Low)
                return QualityLevel.Low;
            return QualityLevel.Custom;
        }

        #endregion

        #region 抗锯齿
        public static void SetAntiAliasing(QualityLevel level)
        {
            //int qualityLevel = QualitySettings.GetQualityLevel();
            //UniversalRenderPipelineAsset urpAsset = (UniversalRenderPipelineAsset)QualitySettings.GetRenderPipelineAssetAt(qualityLevel);

            //switch (level)
            //{
            //    case QualityLevel.High:
            //        urpAsset.msaaSampleCount = 4;
            //        break;
            //    case QualityLevel.Middle:
            //        urpAsset.msaaSampleCount = 2;
            //        break;
            //    case QualityLevel.Low:
            //        urpAsset.msaaSampleCount = 1;
            //        break;
            //    default:
            //        break;
            //}
        }

        public static QualityLevel GetAntiAliasing()
        {
            //int qualityLevel = QualitySettings.GetQualityLevel();
            //UniversalRenderPipelineAsset urpAsset = (UniversalRenderPipelineAsset)QualitySettings.GetRenderPipelineAssetAt(qualityLevel);

            //if (urpAsset.msaaSampleCount == 4)
            //    return QualityLevel.High;
            //else if (urpAsset.msaaSampleCount == 2)
            //    return QualityLevel.Middle;
            //else if (urpAsset.msaaSampleCount == 1)
            //    return QualityLevel.Low;
            return QualityLevel.Custom;
        }

        #endregion

        /// <summary>
        /// 设置辉光
        /// </summary>
        /// <param name="shadow"></param>
        public static void SetBloom()
        {

        }
    }
}